<?php
/**
 * Created by PhpStorm.
 * User: hehecat
 * Date: 2018/8/29
 * Time: 20:37
 */

namespace app\admin\model;


use think\Db;
use think\Model;

class VideoModel extends Model {

    public function getVideo($admin_id) {
        $club_id = Db::table('admin')->where('adminid',$admin_id)->find()['clubid'];
        $video = Db::table('video')->where('clubid',$club_id)->select();
        return $video;
    }

    public function editVideo($video_id, $name, $src, $intro) {
      $result = Db::table('video')
            ->where('videoid', $video_id)
            ->update([
                'videoname'  => $name,
                'intro' => $intro,
                'videosrc' =>  $src,
            ]);

      return $result;
    }
    public function editVideo2($video_id, $name, $intro) {
      $result = Db::table('video')
            ->where('videoid', $video_id)
            ->update([
                'videoname'  => $name,
                'intro' => $intro,
            ]);

      return $result;
    }

    public function getVIdeoSrc($videoid) {
        $club_id = Db::table('video')->where('videoid',$videoid)->find();
        return $club_id;
    }
    public function deleteVideo($video_id) {
        $result =  Db::table('video')->delete($video_id);
        return $result;
    }

    public function addVideo($admin_id, $name, $src, $intro) {
        $club_id = Db::table('admin')->where('adminid',$admin_id)->find()['clubid'];
        $data = ['videoname' => $name, 'videosrc' => $src, 'intro'=>$intro, 'clubid'=>$club_id];
        $result = Db::table('video')->insert($data);
        return $result;
    }
}